package com.ztgf.pay.common.listener;

import com.trz.netwk.api.system.InitSystem;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 中金聚道初始化加载
 *
 * @author fcy
 * @Date 2019-07-04 22:49:37
 */
@Component
@Order(1)
@Slf4j
public class ZjListener implements ApplicationListener<ContextRefreshedEvent> {
    @Value("${zj-pay.cert-url}")
    private String netwkConfigPath;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        // 初始化系统环境
        try {
            // 初始化支付环境
//            PaymentEnvironment.initialize(netwkConfigPath);
            InitSystem.initialize(netwkConfigPath);
            log.info("中金系统初始化....");
            log.info("paymentURL[" + InitSystem.TRZ_URL + "]");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
